<template>
    <div>
        <h3>销售信息查询</h3>
        <el-table
                :data="tableData.slice((currentPage-1)*PageSize,currentPage*PageSize)"
                style="width: 100%">
            <el-table-column
                    label="客户名称"
                    prop="customName">
            </el-table-column>
            <el-table-column
                    label="销售员"
                    prop="employeeName">
            </el-table-column>
            <el-table-column
                    label="采购时间"
                    prop="date">
            </el-table-column>
            <el-table-column
                    align="right">
                <template slot-scope="scope">
                    <el-button
                            size="mini"
                            @click="handleEdit(scope.row.sellId)">查看详情
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
        <div class="tabListPage">
            <el-pagination @size-change="handleSizeChange"
                           @current-change="handleCurrentChange"
                           :current-page="currentPage"
                           :page-sizes="pageSizes"
                           :page-size="PageSize" layout="total, sizes, prev, pager, next, jumper"
                           :total="totalCount">
            </el-pagination>
        </div>

        <div style="width:600px; height: 400px; border: 2px solid;">
            <span>--查询出库信息--</span>
            <el-form ref="customerForm">
                <el-row>
                    <el-form-item label="客户名称：" prop="customName">
                        <el-input v-model="customerName"></el-input>
                    </el-form-item>
                </el-row>
                <el-row style="margin-top: 10px">
                    <el-form-item label="起始时间：" prop="startDate">
                        <el-input v-model="startDate"></el-input>
                    </el-form-item>
                </el-row>
                <el-row style="margin-top: 10px">
                    <el-form-item label="结束时间：" prop="endDate">
                        <el-input v-model="endDate"></el-input>
                    </el-form-item>
                </el-row>
            </el-form>
            <el-button @click="init()">查询</el-button>
        </div>
    </div>
</template>

<script>
    export default {
        name: "SalesInfoView",
        data() {
            return {
                customerName:'',
                startDate:'',
                endDate:'',

                tableData: [],
                search: '',
                totalCount:null,
                // 默认显示第几页
                currentPage:1,
                // 个数选择器（可修改）
                pageSizes:[1,2,3,4],
                // 默认每页显示的条数（可修改）
                PageSize:3,
            }
        },

        mounted() {
            this.init()
        },

        methods: {
            init(){
                let url = "api/sell/findByItem?endDate="+this.endDate+
                    "&name="+this.customerName+"&startDate="+this.startDate
                this.$axios.get(url).then(r =>{
                    console.log(r.data)
                    this.tableData = r.data;
                })
            },
            handleEdit(id) {
                this.$store.state.sellId =id;
                this.$router.push("SaleList")
            },


            handleSizeChange(size) {
                // 改变每页显示的条数
                this.PageSize=size
                // 注意：在改变每页显示的条数时，要将页码显示到第一页
                this.currentPage=1
            },
            // 显示第几页
            handleCurrentChange(size) {
                // 改变默认的页数
                this.currentPage=size
            },
        },
    }
</script>

<style scoped>

</style>